package javaLearning.数据库连接池.ConnectionPool.Pool;

import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
/**
 * 读取properties配置文件
 * @author : K k
 * @date : 23:02 2020/10/11
 */
public class PropertiesManager {
    private static Properties pro = new Properties();

    static {
        try {
            pro.load(PropertiesManager.class.getClassLoader().getResourceAsStream("javaLearning/数据库连接池/ConnectionPool/config/DB.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private PropertiesManager() {
    }

    public static String getProperty(String key) {
        return pro.getProperty(key);
    }

    public static String getProperty(String key, String defaultValue) {
        return pro.getProperty(key, defaultValue);
    }

    public static Enumeration<?> propertiesNames() {
        return pro.propertyNames();
    }

    public static void main(String[] args) {
        System.out.println(PropertiesManager.getProperty("nodename"));
    }
}